package src.cs2340.todoApp;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * CategoryComparatorTest.java 
 * Will check the compare method in CategoryComparator.
 */

public class CategoryComparatorTest {
	
	Location home, school, work;
	Date today, tomorrow;
	TaskItem t1, t2, t3;
	CategoryComparator c;

	@Before
	public void setUp() throws Exception { }

	/**
	 * @author Kristian
	 * Will test if one category's ASCII value is less than the other that a negative number
	 * is returned from the compare method.  If the left category has a greater ASCII value
	 * than the right category, then is a positive number returned?  If they're equal, it
	 * should return 0.
	 */
	@Test
	public void testCompare() {
		c = new CategoryComparator();
		
		home = new Location("home", 55, "Deville Drive", "Villa", "CA", 77233);
		today = new Date(2, 4, 2012, 4, 22, Date.Meredian.PM);//4:22PM 4-2-2012
		
		TaskItem t1 = new TaskItem("play video games", home, today, "video games are fun! :D"
				, "home", false);
		
		school = new Location("GA Tech", 225, "North Avenue", "Atlanta", "GA", 30332);
		tomorrow = new Date(3, 4, 2012, 11, 11, Date.Meredian.AM);//11:11AM 4-3-2012
		
		TaskItem t2 = new TaskItem("do m10", school, tomorrow, "why u no work?", 
				"school", true);
		
		work = new Location("Heaven/Hell", 666777, "Crossroad of Pain and Pleasure", 
				"some place in Florida", "FL", 67888);
		
		TaskItem t3 = new TaskItem("make video games", work, tomorrow, "make something cool!", 
				"work", false);
		
		TaskItem t4 = new TaskItem("make moar video games", work, tomorrow, "make moar kool stuff!", 
				"emoh", true);
		
		assertEquals("home's ASCII value should be less than school's, but wasn't" + c.compare(t1, t2)
				, c.compare(t1, t2), -11);
		assertEquals("school's ASCII value should be greater than work's, but wasn't" + c.compare(t2, t3)
				, c.compare(t2, t3), -4);
		assertEquals("work's ASCII value should be greater than home's but wasn't" + c.compare(t3, t1)
				, c.compare(t3, t1), 15);
		assertEquals("home and emoh have the same letters, but the categories of their respective tasks" +
				"aren't equal for some reason...", c.compare(t1, t4), c.compare(t1, t4), 0);
	}

}
